/**
    社区管理【模板】
    push mirthapi@965f6ae9-fef8-4e62-87df-6ad8f65636af
    @time:2021-4-6 12:21
    @author:kakake
    */
({
    data: {
        resultdata: {},
        dbConn: Program.data.dbConn,
        WorkId: Program.data.WorkId,
        requestBody: Program.data.requestBody,
        BloggerModel: {
            model: {
                BloggerId: 0,
                ConcernedCount: 0,
                fansCount: 0,
                LikesCount: 0,
                Slogan: "",
                WorkId: 0,
                UserId: "",
                NickName: "",
                UserImg: "",
                UserBackImg: "",
                "Level": 0,
                DelFlag: 0,
            },
            tablename: "Co_Blogger",
            key: "BloggerId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        BloggerConcernModel: {
            model: {
                ConcerId: 0,
                BloggerId: 0,
                IsConcern: 0,
                ConcernUserId: "",
                UserId: "",
                WorkId: 0,
                DelFlag: 0,
            },
            tablename: "Co_BloggerConcern",
            key: "ConcerId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        DynamicModel: {
            model: {
                DynamicId: 0,
                BloggerId: 0,
                TopicId: 0,
                Title: "",
                "Content": "",
                UserId: "",
                Location: "",
                Limit: 0,
                LikesCount: 0,
                EvaluateCount: 0,
                PlanId: 0,
                CourseId: 0,
                WorkId: 0,
                DelFlag: 0,
                TempJson: "",
                CreateTime: "yyyy-MM-dd HH:mm:ss",
                DynamicType: 0,

            },
            tablename: "Co_Dynamic",
            key: "DynamicId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        DynamicAttachModel: {
            model: {
                AttachId: 0,
                DynamicId: 0,
                Type: 0,
                Url: "",
                UserId: "",
                WorkId: 0,
                DelFlag: 0,
                Duration: 0,
                Height: 0,
                Width: 0,
            },
            tablename: "Co_DynamicAttach",
            key: "AttachId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        DynamicEvaluateModel: {
            model: {
                EvaluateId: 0,
                DynamicId: 0,
                "Content": "",
                UserId: "",
                EvaluateTime: "yyyy-MM-dd HH:mm:ss",
                PId: 0,
                LikesCount: 0,
            },
            tablename: "Co_DynamicEvaluate",
            key: "EvaluateId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        DynamicEvaluateRelatedModel: {
            model: {
                RelatedId: 0,
                EvaluateId: 0,
                IsLike: 0,
                UserId: "",
                WorkId: 0,
            },
            tablename: "Co_DynamicEvaluateRelated",
            key: "RelatedId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        DynamicRelatedModel: {
            model: {
                RelatedId: 0,
                DynamicId: 0,
                IsCollection: 0,
                IsLike: 0,
                IsReport: 0,
                ReportContent: "",
                UserId: "",
                WorkId: 0,
                ReportType: 0,
                ReportDesc: "",
                ReportTime: "yyyy-MM-dd HH:mm:ss",
                ReportUserId: "",
                AuditResult: 0,
                AuditDesc: "",
                Auditor: "",
                AuditTime: "yyyy-MM-dd HH:mm:ss",
                IsSend: 0,
            },
            tablename: "Co_DynamicRelated",
            key: "RelatedId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        TopicModel: {
            model: {
                TopicId: 0,
                TopicName: "",
                TopicType: 0,
                TopicDesc: "",
                LookersCount: 0,
                WorkId: 0,
                DelFlag: 0,
                BackImg: "",
                CreateTime: "yyyy-MM-dd HH:mm:ss",
            },
            tablename: "Co_Topic",
            key: "TopicId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
        TopicConcernModel: {
            model: {
                ConcerId: 0,
                TopicId: 0,
                IsConcern: 0,
                UserId: "",
                WorkId: 0,
                DelFlag: 0,
            },
            tablename: "Co_TopicConcern",
            key: "ConcerId",
            val: "0",
            objval: {},
            WorkId: LobsterAPI.ProgramData('workid')
        },
    },
    main: function (funname) {
        var self = this;
        self.data.dbConn = PublicFunction.setdbconn('10.0.4.5:1433', 'CloudCommunity', 'sa', 'Lobster@123');
        if (funname == "Dynamic.GetDynamicList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var searchkey = LobsterAPI.RequestQuery("searchkey", "");
            var userId = LobsterAPI.RequestQuery("userId", -1);
            self.data.resultdata = self.GetDynamicList(page, limit, searchkey, userId);
        }
        else if (funname == "Dynamic.GetFollowDynamicList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var searchkey = LobsterAPI.RequestQuery("searchkey", "");
            var userId = LobsterAPI.RequestQuery("userId", -1);
            self.data.resultdata = self.GetFollowDynamicList(page, limit, searchkey, userId);
        }
        else if (funname == "Dynamic.GetTopicList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var searchkey = LobsterAPI.RequestQuery("searchkey", "");
            var topictype = LobsterAPI.RequestQuery("topictype", -1);
            self.data.resultdata = self.GetTopicList(page, limit, searchkey, topictype);
        }
        else if (funname == "Dynamic.LikeDynamic") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.LikeDynamic(model);
        }
        else if (funname == "Dynamic.CollectDynamic") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.CollectDynamic(model);
        }
        else if (funname == "Dynamic.GetEvaluateList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var dynamicId = LobsterAPI.RequestQuery("dynamicId", -1);
            var sort = LobsterAPI.RequestQuery("sort", -1);
            var userId = LobsterAPI.RequestQuery("userId", -1);
            self.data.resultdata = self.GetEvaluateList(page, limit, dynamicId, sort, userId);
        }
        else if (funname == "Dynamic.EvaluateDynamic") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.EvaluateDynamic(model);
        }
        else if (funname == "Dynamic.LikeEvaluate") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.LikeEvaluate(model);
        }
        else if (funname == "Dynamic.GetDynamicDetail") {
            var userId = LobsterAPI.RequestQuery("userId", -1);
            var dynamicId = LobsterAPI.RequestQuery("dynamicId", -1);
            self.data.resultdata = self.GetDynamicDetail(userId, dynamicId);
        }
        else if (funname == "Dynamic.FollowBlogger") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.FollowBlogger(model);
        }
        else if (funname == "Dynamic.DeleteDynamic") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.DeleteDynamic(model);
        }
        else if (funname == "Dynamic.ReportDynamic") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.ReportDynamic(model);
        }
        else if (funname == "Dynamic.SaveDynamic") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.SaveDynamic(model);
        }
        else if (funname == "Dynamic.GetMoreEvaluateList") {
            var pId = LobsterAPI.RequestQuery("pId", -1);
            var dynamicId = LobsterAPI.RequestQuery("dynamicId", -1);
            self.data.resultdata = self.GetMoreEvaluateList(dynamicId, pId);
        }
        else if (funname == "Dynamic.GetBloggerDetail") {
            var userId = LobsterAPI.RequestQuery("userId", "");
            var bloggerId = LobsterAPI.RequestQuery("bloggerId", -1);
            self.data.resultdata = self.GetBloggerDetail(userId, bloggerId);
        } else if (funname == "Dynamic.GetBlogger") {
            var userId = LobsterAPI.RequestQuery("userId", "");
            self.data.resultdata = self.GetBlogger(userId);
        }
        else if (funname == "Dynamic.GetBloggerAttachList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var bloggerId = LobsterAPI.RequestQuery("bloggerId", -1);
            var type = LobsterAPI.RequestQuery("type", -1);
            self.data.resultdata = self.GetBloggerAttachList(page, limit, bloggerId, type);
        } else if (funname == "Dynamic.GetBloggerDynamicList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var bloggerId = LobsterAPI.RequestQuery("bloggerId", -1);
            var userId = LobsterAPI.RequestQuery("userId", "");
            self.data.resultdata = self.GetBloggerDynamicList(page, limit, bloggerId, userId);
        } else if (funname == "Dynamic.SaveBloggerBackImg") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.SaveBloggerBackImg(model);
        } else if (funname == "Dynamic.SaveBloggerSlogan") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.SaveBloggerSlogan(model);
        } else if (funname == "Dynamic.SaveBlogger") {
            var model = JSON.parse(self.data.requestBody);
            LobsterAPI.TrackLog("dynamic.saveblogger", model)
            self.data.resultdata = self.SaveBlogger(model);
        } else if (funname == "Dynamic.GetTopicByTopicId") {
            var topicId = LobsterAPI.RequestQuery("topicId", -1);
            var userId = LobsterAPI.RequestQuery("userId", "");
            self.data.resultdata = self.GetTopicByTopicId(topicId, userId);
        } else if (funname == "Dynamic.FollowTopic") {
            var model = JSON.parse(self.data.requestBody);
            self.data.resultdata = self.FollowTopic(model);
        } else if (funname == "Dynamic.GetTopicDynamicList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var topicId = LobsterAPI.RequestQuery("topicId", -1);
            var userId = LobsterAPI.RequestQuery("userId", "");
            self.data.resultdata = self.GetTopicDynamicList(page, limit, topicId, userId);
        } else if (funname == "Dynamic.GetBloggerList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var searchkey = LobsterAPI.RequestQuery("searchkey", "");
            var userId = LobsterAPI.RequestQuery("userId", "");
            self.data.resultdata = self.GetBloggerList(searchkey, userId, page, limit);

        } else if (funname == "Dynamic.GetConcernTopicList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var userId = LobsterAPI.RequestQuery("userId", "");
            self.data.resultdata = self.GetConcernTopicList(page, limit, userId);

        } else if (funname == "Dynamic.GetConcernList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var searchkey = LobsterAPI.RequestQuery("searchkey", "");
            var userId = LobsterAPI.RequestQuery("userId", "");
            var bloggerUserId = LobsterAPI.RequestQuery("bloggerUserId", "");
            self.data.resultdata = self.GetConcernList(searchkey, userId, bloggerUserId, page, limit);
        } else if (funname == "Dynamic.GetFansList") {
            var page = LobsterAPI.RequestQuery("page", 1);
            var limit = LobsterAPI.RequestQuery("limit", 10);
            var searchkey = LobsterAPI.RequestQuery("searchkey", "");
            var userId = LobsterAPI.RequestQuery("userId", "");
            var bloggerUserId = LobsterAPI.RequestQuery("bloggerUserId", "");
            self.data.resultdata = self.GetFansList(searchkey, userId, bloggerUserId, page, limit);
        } else if (funname == "Dynamic.GetShieldWordList") {
            self.data.resultdata = self.GetShieldWordList();
        }

        return self.data.resultdata;
    },
    GetDynamicList(page, limit, searchkey, userId) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "CreateTime desc";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.*,b.NickName,b.UserImg,c.TopicName, convert(varchar(2000),(SELECT Url+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Attachs,\
        convert(varchar(2000),(SELECT convert(varchar(20), Duration)+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Durations,\
        convert(varchar(2000),(SELECT convert(varchar(20), Height)+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Heights,\
        convert(varchar(2000),(SELECT convert(varchar(20), Width)+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Widths,\
            e.IsLike,e.IsCollection,e.IsReport,ISNULL(d.IsConcern,0) as IsConcern\
            from Co_Dynamic a\
            inner join Co_Blogger b \
            on a.UserId=b.UserId\
            left join Co_Topic c\
            on a.TopicId=c.TopicId\
            left join Co_DynamicRelated e\
            on a.DynamicId=e.DynamicId and e.UserId=?\
            left join Co_BloggerConcern d\
            on b.BloggerId=d.BloggerId and d.UserId=? and d.IsConcern=1 and b.UserId=d.ConcernUserId\
            where a.WorkId=? and a.DelFlag=0 and (a.Limit = 1 or a.UserId=?) and isnull(e.IsReport,0)=0";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId); dbparams.add(userId); dbparams.add(self.data.WorkId); dbparams.add(userId)
        if (searchkey != "") {
            strsql += " and a.Title like ? ";
            dbparams.add("%" + searchkey + "%");
        }
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    GetFollowDynamicList(page, limit, searchkey, userId) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "CreateTime desc";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.*,b.NickName,b.UserImg,c.TopicName,Convert(varchar(2000),(SELECT Url+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Attachs,\
            e.IsLike,e.IsCollection,e.IsReport,ISNULL(d.IsConcern,0) as IsConcern\
            from Co_Dynamic a\
            inner join Co_Blogger b \
            on a.UserId=b.UserId\
            left join Co_Topic c\
            on a.TopicId=c.TopicId\
            left join Co_DynamicRelated e\
            on a.DynamicId=e.DynamicId and e.UserId=?\
            inner join Co_BloggerConcern d\
            on b.BloggerId=d.BloggerId and d.UserId=? and d.IsConcern=1  and b.UserId=d.ConcernUserId\
            where a.WorkId=? and a.DelFlag=0\
            and a.Limit = 1 and isnull(e.IsReport,0)=0\
            union all\
            select a.*,b.NickName,b.UserImg,c.TopicName,Convert(varchar(2000),(SELECT Url+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Attachs,\
            e.IsLike,e.IsCollection,e.IsReport,0 IsConcern\
            from Co_Dynamic a\
            inner join Co_Blogger b\
            on a.UserId=b.UserId\
            left join Co_Topic c\
            on a.TopicId=c.TopicId\
            left join Co_DynamicRelated e\
            on a.DynamicId=e.DynamicId and e.UserId=?  and b.UserId=e.UserId\
            where a.WorkId=? and a.DelFlag=0\
            and  a.UserId=? ";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId); dbparams.add(userId); dbparams.add(self.data.WorkId);
        dbparams.add(userId); dbparams.add(userId); dbparams.add(self.data.WorkId);
        if (searchkey != "") {
            strsql += " and a.Title like ? ";
            dbparams.add("%" + searchkey + "%");
        }
        LobsterAPI.TrackLog("getfollowdynamicsql", strsql);
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    GetTopicList(page, limit, searchkey, topictype) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "LookersCount desc";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select * from Co_Topic Where WorkId=? "
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(self.data.WorkId);
        if (searchkey != "") {
            strsql += " and TopicName like ?";
            dbparams.add("%" + searchkey + "%");
        }
        if (topictype > 0) {
            strsql += " and TopicType=?";
            dbparams.add(topictype);
        }
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        data.forEach(a => {
            a.dynamic = self.GetLasetestDynamic(a.TopicId);
        })
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    GetLasetestDynamic(topicId) {
        var self = this;
        var strsql = "select top 1 a.Content,b.NickName,a.CreateTime,Convert(varchar(2000),(SELECT Url + ',' from Co_DynamicAttach where DynamicId = a.DynamicId FOR XML PATH(''))) as Attachs\
            from Co_Dynamic a\
            inner\
            join Co_Blogger b\
            on a.UserId = b.UserId\
            where TopicId =? order by CreateTime desc";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(topicId);
        return ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
    },
    GetDynamicById(dynamicId) {
        var self = this;
        var strsql = "select * from Co_Dynamic where DynamicId=?"
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(dynamicId);
        return ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
    },
    GetBloggerById(bloggerId) {
        var self = this;
        var strsql = "select * from Co_Blogger where BloggerId=?"
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(bloggerId);
        return ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
    },
    GetBloggerByUserId(userId) {
        var self = this;
        var strsql = "select * from Co_Blogger where UserId=?"
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        return ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
    },
    GetBloggerConcern(userI, concernUserId) {
        var self = this;
        var strsql = "select * from Co_BloggerConcern where UserId=? and ConcernUserId=?"
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userI);
        dbparams.add(concernUserId);
        return ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
    },
    GetDynamicRelated(dynamicId, userId) {
        var self = this;
        var strsql = "select * from Co_DynamicRelated where DynamicId=? and UserId=?"
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(dynamicId);
        dbparams.add(userId);
        return ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
    },
    GetDynamicEvaluateById(evaluateId) {
        var self = this;
        var strsql = "select * from Co_DynamicEvaluate where EvaluateId=?"
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(evaluateId);
        return ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
    },
    GetDynamicEvaluateRelated(evaluateId, userId) {
        var self = this;
        var strsql = "select * from Co_DynamicEvaluateRelated where EvaluateId=? and UserId=?"
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(evaluateId);
        dbparams.add(userId);
        return ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
    },
    GetTopicById(topicId, userId) {
        var self = this;
        var strsql = "select a.*,ISNULL(d.IsConcern, 0) IsConcern from Co_Topic a\
        left join Co_TopicConcern d\
        on a.TopicId = d.TopicId and d.UserId=?\
        where a.TopicId = ?"
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        dbparams.add(topicId);
        return ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
    },

    GetTopicConcern(topicId, userId) {
        var self = this;
        var strsql = "select * from Co_TopicConcern where TopicId=? and UserId=?"
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(topicId);
        dbparams.add(userId);
        return ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
    },
    LikeDynamic(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var dynamic = self.GetDynamicById(model.DynamicId);
            if (!dynamic.DynamicId)
                return { code: 1, msg: "找不到动态" };
            var blogger = self.GetBloggerById(model.BloggerId);
            if (!blogger.BloggerId)
                return { code: 1, msg: "找不到博主" };
            var dynamicRelated = self.GetDynamicRelated(model.DynamicId, model.UserId);
            if (dynamicRelated.RelatedId > 0) {
                dynamicRelated.IsLike = model.IsLike;
            } else {
                dynamicRelated = {
                    DynamicId: model.DynamicId,
                    IsLike: model.IsLike,
                    UserId: model.UserId,
                    WorkId: self.data.WorkId
                }
            }
            self.data.DynamicRelatedModel.objval = dynamicRelated;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicRelatedModel);
            //更新动态点赞数
            if (model.IsLike == 0) {
                dynamic.LikesCount--;
                if (dynamic.LikesCount < 0)
                    dynamic.LikesCount = 0;
            } else
                dynamic.LikesCount++;
            self.data.DynamicModel.objval = dynamic;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicModel);
            //更新博主点赞数
            if (model.IsLike == 0) {
                blogger.LikesCount--;
                if (blogger.LikesCount < 0)
                    blogger.LikesCount = 0;
            }
            else
                blogger.LikesCount++;
            self.data.BloggerModel.objval = blogger;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.BloggerModel);
            self.data.dbConn.commit();
            return { code: 0, data: { dynamic: dynamic } };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    CollectDynamic(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var dynamic = self.GetDynamicById(model.DynamicId);
            if (!dynamic.DynamicId)
                return { code: 1, msg: "找不到动态" };
            var dynamicRelated = self.GetDynamicRelated(model.DynamicId, model.UserId);
            if (dynamicRelated.RelatedId > 0) {
                dynamicRelated.IsCollection = model.IsCollection;
            } else {
                dynamicRelated = {
                    DynamicId: model.DynamicId,
                    IsCollection: model.IsCollection,
                    UserId: model.UserId,
                    WorkId: self.data.WorkId
                }
            }
            self.data.DynamicRelatedModel.objval = dynamicRelated;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicRelatedModel);
            self.data.dbConn.commit();
            return { code: 0, data: { dynamic: dynamic } }
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    GetChildEvaluateList(page, limit, dynamicId, pid, userId) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "EvaluateTime desc";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.*,b.UserImg,b.NickName,isnull(c.IsLike,0) IsLike from Co_DynamicEvaluate a\
            inner join Co_Blogger b\
            on a.UserId = b.UserId\
            left join Co_DynamicEvaluateRelated c\
            on a.EvaluateId=c.EvaluateId and c.UserId=?\
            where a.DynamicId = ? and a.PId = ?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        dbparams.add(dynamicId);
        dbparams.add(pid);
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { ChildList: data, ChildNum: pageInfo.totalRecord };
    },
    GetEvaluateList(page, limit, dynamicId, sort, userId) {
        var self = this;
        var pageInfo = {};
        if (sort == 0) {
            pageInfo.key = "EvaluateTime desc";
        }
        else {
            pageInfo.key = "LikesCount desc";
        }
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.*,b.UserImg,b.NickName,isnull(c.IsLike,0) IsLike from Co_DynamicEvaluate a\
            inner join Co_Blogger b\
            on a.UserId = b.UserId\
            left join Co_DynamicEvaluateRelated c\
            on a.EvaluateId=c.EvaluateId and c.UserId=?\
            where a.DynamicId = ? and a.PId = 0";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        dbparams.add(dynamicId);
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        data.forEach(a => {
            var child = self.GetChildEvaluateList(1, 2, dynamicId, a.EvaluateId, userId);
            a.ChildList = child.ChildList;
            a.ChildNum = child.ChildNum;
        })
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    EvaluateDynamic(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var dynamic = self.GetDynamicById(model.DynamicId);
            if (!dynamic.DynamicId)
                return { code: 1, msg: "找不到动态" };
            //更新动态评论数
            dynamic.EvaluateCount++;
            self.data.DynamicModel.objval = dynamic;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicModel);
            //新增评论
            model.EvaluateTime = self.getCurrTime();
            self.data.DynamicEvaluateModel.objval = model;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicEvaluateModel);
            var blogger = self.GetBloggerByUserId(model.UserId);
            if (blogger.BloggerId > 0) {
                model.UserImg = blogger.UserImg;
                model.NickName = blogger.NickName;
            }
            self.data.dbConn.commit();
            return { code: 0, data: { evaluate: model, dynamic: dynamic } };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    LikeEvaluate(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var dynamicEvaluate = self.GetDynamicEvaluateById(model.EvaluateId);
            if (!dynamicEvaluate.EvaluateId)
                return { code: 1, msg: "找不到动态评论" };
            var evaluateRelated = self.GetDynamicEvaluateRelated(model.EvaluateId, model.UserId);
            if (evaluateRelated.RelatedId > 0) {
                evaluateRelated.IsLike = model.IsLike;
            } else {
                evaluateRelated = {
                    EvaluateId: model.EvaluateId,
                    IsLike: model.IsLike,
                    UserId: model.UserId,
                    WorkId: self.data.WorkId
                }
            }
            self.data.DynamicEvaluateRelatedModel.objval = evaluateRelated;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicEvaluateRelatedModel);
            if (model.IsLike == 0) {
                dynamicEvaluate.LikesCount--;
                if (dynamicEvaluate.LikesCount < 0)
                    dynamicEvaluate.LikesCount = 0;
            }
            else {
                dynamicEvaluate.LikesCount++;
            }
            self.data.DynamicEvaluateModel.objval = dynamicEvaluate;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicEvaluateModel);
            self.data.dbConn.commit();
            return { code: 0, data: { evaluate: dynamicEvaluate } };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    GetDynamicDetail(userId, dynamicId) {
        var self = this;
        var strsql = "select a.*,b.NickName,b.UserImg,c.TopicName,convert(varchar(2000),(SELECT Url+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Attachs,\
            e.IsLike,e.IsCollection,e.IsReport,ISNULL(d.IsConcern,0) as IsConcern\
            from Co_Dynamic a\
            inner join Co_Blogger b\
            on a.UserId=b.UserId\
            left join Co_Topic c\
            on a.TopicId=c.TopicId\
            left join Co_DynamicRelated e\
            on a.DynamicId=e.DynamicId\
            left join Co_BloggerConcern d\
            on b.BloggerId=d.BloggerId and d.UserId=?  and d.IsConcern=1 and b.UserId=d.ConcernUserId\
            where a.DynamicId=?"
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        dbparams.add(dynamicId);
        var detail = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { detail: detail } };
    },
    FollowBlogger(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var blogger = self.GetBloggerByUserId(model.ConcernUserId);
            if (!blogger.BloggerId)
                return { code: 1, msg: "找不到博主" };
            var loginblogger = self.GetBloggerByUserId(model.UserId);
            if (!loginblogger.BloggerId)
                return { code: 1, msg: "找不到博主" };
            var bloggerConcern = self.GetBloggerConcern(model.UserId, model.ConcernUserId);
            if (bloggerConcern.ConcerId > 0) {
                bloggerConcern.IsConcern = model.IsConcern;
            } else {
                bloggerConcern = {
                    BloggerId: model.BloggerId,
                    IsConcern: model.IsConcern,
                    ConcernUserId: model.ConcernUserId,
                    UserId: model.UserId,
                    WorkId: self.data.WorkId
                }
            }
            self.data.BloggerConcernModel.objval = bloggerConcern;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.BloggerConcernModel);
            LobsterAPI.TrackLog("Dynamic.FollowBlogger1", "---------------");
            if (model.IsConcern == 1) {
                blogger.fansCount++;
                loginblogger.ConcernedCount++;
            }
            else {
                blogger.fansCount--;
                loginblogger.ConcernedCount--;
                if (blogger.fansCount < 0) {
                    blogger.fansCount = 0;
                }
                if (loginblogger.ConcernedCount < 0) {
                    loginblogger.ConcernedCount = 0;
                }
            }
            self.data.BloggerModel.objval = blogger;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.BloggerModel);
            LobsterAPI.TrackLog("Dynamic.FollowBlogger1", "11111111111111111111");
            self.data.BloggerModel.objval = loginblogger;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.BloggerModel);
            LobsterAPI.TrackLog("Dynamic.FollowBlogger1", "222222222222222222");
            self.data.dbConn.commit();
            return { code: 0, data: { blogger: blogger } };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    DeleteDynamic(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var dynamic = self.GetDynamicById(model.DynamicId);
            if (!dynamic.DynamicId)
                return { code: 1, msg: "找不到该动态"};
            if (dynamic.UserId != model.UserId) {
                return { code: 1, msg: "不能删除非本人动态" };
            }
            dynamic.DelFlag = 1;
            self.data.DynamicModel.objval = dynamic;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicModel);
            self.data.dbConn.commit();
            return { code: 0, data: { dynamic: dynamic } };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    ReportDynamic(model) {
        var self = this;
        try {
            // return {code:1,msg:"sfafasf",data:"sfsdfdsfdsfds"};
            LobsterAPI.TrackLog("ReportDynamic", "111111");
            var dynamic = self.GetDynamicById(model.DynamicId);
            if (!dynamic.DynamicId)
                return { code: 1, msg: "找不到该动态" };
            LobsterAPI.TrackLog("ReportDynamic", "222222");
            var dynamicRelated = self.GetDynamicRelated(model.DynamicId, model.UserId);
            if (dynamicRelated2121.AuditResult != null) {
                return { code: 1, msg: "后台已经审核" };
            }
            LobsterAPI.TrackLog("ReportDynamic", "333333");
            self.data.dbConn.setAutoCommit(false);
            if (dynamicRelated.RelatedId > 0) {
                dynamicRelated.IsReport = model.IsReport;
                dynamicRelated.ReportContent = model.ReportContent;
                dynamicRelated.ReportDesc = model.ReportDesc;
                dynamicRelated.ReportType = model.ReportType;
                dynamicRelated.ReportUserId = model.ReportUserId;
                dynamicRelated.ReportTime = self.getCurrTime();
            } else {
                dynamicRelated.DynamicId = model.DynamicId;
                dynamicRelated.IsReport = model.IsReport;
                dynamicRelated.ReportContent = model.ReportContent;
                dynamicRelated.ReportDesc = model.ReportDesc;
                dynamicRelated.ReportType = model.ReportType;
                dynamicRelated.ReportTime = self.getCurrTime();
                dynamicRelated.UserId = model.UserId;
                dynamicRelated.ReportUserId = model.ReportUserId;
                dynamicRelated.WorkId = self.data.WorkId;
            }
            self.data.DynamicRelatedModel.objval = dynamicRelated;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicRelatedModel);

            self.data.dbConn.commit();
            return { code: 0 };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    SaveDynamic(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var blogger = self.GetBloggerByUserId(model.UserId);
            if (!blogger.BloggerId)
                return { code: 1, msg: "博主信息不完善" };
            model.CreateTime = self.getCurrTime();
            model.BloggerId = blogger.BloggerId;
            model.WorkId = self.data.WorkId;
            self.data.DynamicModel.objval = model;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicModel);
            var attachlist = JSON.parse(model.AttachList);
            attachlist.forEach(item => {
                item.DynamicId = self.data.DynamicModel.objval.DynamicId;
                item.UserId = model.UserId;
                item.WorkId = self.data.WorkId;
                self.data.DynamicAttachModel.objval = item;
                LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.DynamicAttachModel);
            })
            self.data.dbConn.commit();
            return { code: 0 };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    GetMoreEvaluateList(dynamicId, pId) {
        var self = this;
        var strsql = "select a.*,b.UserImg,b.NickName from Co_DynamicEvaluate a\
            inner join Co_Blogger b\
            on a.UserId = b.UserId\
            where a.DynamicId = ? and a.PId = ? order by EvaluateTime desc";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(dynamicId);
        dbparams.add(pId);
        var list = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { list: list } };
    },
    GetBloggerDetail(userId, bloggerId) {
        var self = this;
        var strsql = "select a.*,ISNULL(b.IsConcern,0) IsConcern from Co_Blogger a\
            left join Co_BloggerConcern b\
            on a.BloggerId=b.BloggerId and a.UserId=b.ConcernUserId  and b.UserId=?\
            where a.BloggerId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        dbparams.add(bloggerId);
        var blogger = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { blogger: blogger } };
    },
    GetBlogger(userId) {
        var self = this;
        var strsql = "select * from Co_Blogger where UserId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        var blogger = ORMFunction.GetJsonObject(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { blogger: blogger } };
    },
    GetBloggerAttachList(page, limit, bloggerId, type) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "AttachId desc";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.* from Co_DynamicAttach a\
            inner join Co_Blogger b\
            on a.UserId=b.UserId\
            where b.BloggerId=? and a.Type=? and a.WorkId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(bloggerId);
        dbparams.add(type);
        dbparams.add(self.data.WorkId);
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    GetBloggerDynamicList(page, limit, bloggerId, userId) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "CreateTime desc";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.*,b.NickName,b.UserImg,c.TopicName,convert(varchar(2000),(SELECT Url+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Attachs,\
            (SELECT convert(varchar(20), Duration)+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH('')) as Durations,\
            (SELECT convert(varchar(20), Height)+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH('')) as Heights,\
            (SELECT convert(varchar(20), Width)+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH('')) as Widths,\
            e.IsLike,e.IsCollection,e.IsReport,ISNULL(d.IsConcern,0) as IsConcern\
            from Co_Dynamic a\
            inner join Co_Blogger b  \
            on a.UserId=b.UserId\
            left join Co_Topic c\
            on a.TopicId=c.TopicId\
            left join Co_DynamicRelated e\
            on a.DynamicId=e.DynamicId and e.UserId=?\
            left join Co_BloggerConcern d\
            on b.BloggerId=d.BloggerId and d.UserId=? and b.UserId=d.ConcernUserId\
            where a.WorkId=? and a.DelFlag=0 and a.BloggerId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId); dbparams.add(userId);
        dbparams.add(self.data.WorkId);
        dbparams.add(bloggerId);
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        LobsterAPI.TrackLog("GetBloggerDynamicList", data);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    SaveBloggerBackImg(model) {
        var self = this;
        var newblogger = self.GetBloggerById(model.BloggerId);
        newblogger.UserBackImg = model.UserBackImg;
        self.data.BloggerModel.objval = newblogger;
        LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.BloggerModel);
        return { code: 0 };
    },
    SaveBloggerSlogan(model) {
        var self = this;
        var newblogger = self.GetBloggerById(model.BloggerId);
        newblogger.Slogan = model.Slogan;
        self.data.BloggerModel.objval = newblogger;
        LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.BloggerModel);
        return { code: 0 };
    },
    SaveBlogger(model) {
        try {
            var self = this;
            var blogger = self.GetBloggerByUserId(model.UserId);
            LobsterAPI.TrackLog("dynamic.SaveBlogger", "111111111111");
            if (blogger.BloggerId > 0) {
                blogger.NickName = model.NickName;
                blogger.UserImg = model.UserImg;
            } else {
                blogger = {
                    NickName: model.NickName,
                    UserImg: model.UserImg,
                    UserId: model.UserId,
                    ConcernedCount: 0,
                    fansCount: 0,
                    LikesCount: 0,
                    Slogan: "",
                    UserBackImg: "",
                    "Level": 0,
                    DelFlag: 0,
                }
            }
            self.data.BloggerModel.objval = blogger;
            LobsterAPI.TrackLog("dynamic.SaveBlogger", "22222222222");
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.BloggerModel);
            LobsterAPI.TrackLog("dynamic.SaveBlogger", "3333333333");
            return { code: 0, data: { blogger: blogger } };
        } catch (e) {
            return { code: 1, msg: e.message };
        }
    },
    GetTopicByTopicId(topicId, userId) {
        var self = this;
        var topic = self.GetTopicById(topicId, userId);
        return { code: 0, data: { topic: topic } };
    },
    FollowTopic(model) {
        var self = this;
        try {
            self.data.dbConn.setAutoCommit(false);
            var topic = self.GetTopicById(model.TopicId, model.UserId);
            if (!topic.TopicId)
                return { code: 1, msg: "找不到主题" };
            var topicConcern = self.GetTopicConcern(model.TopicId, model.UserId);
            if (topicConcern.ConcerId > 0) {
                topicConcern.IsConcern = model.IsConcern;
            } else {
                topicConcern.TopicId = model.TopicId;
                topicConcern.IsConcern = model.IsConcern;
                topicConcern.UserId = model.UserId;
                topicConcern.WorkId = self.data.WorkId;
            }
            self.data.TopicConcernModel.objval = topicConcern;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.TopicConcernModel);
            if (model.IsConcern == 1) {
                topic.LookersCount++;
            }
            else {
                topic.LookersCount--;
                if (topic.LookersCount < 0)
                    topic.LookersCount = 0;
            }
            self.data.TopicModel.objval = topic;
            LobsterAPI.OrmMySql.SaveModel(self.data.dbConn, self.data.TopicModel);
            self.data.dbConn.commit();
            return { code: 0 };
        } catch (e) {
            self.data.dbConn.rollback();
            return { code: 1, msg: e.message };
        }
    },
    GetTopicDynamicList(page, limit, topicId, userId) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "CreateTime desc";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.*,b.NickName,b.UserImg,c.TopicName,convert(varchar(2000),(SELECT Url+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Attachs,\
        convert(varchar(2000),(SELECT convert(varchar(20), Duration)+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Durations,\
        convert(varchar(2000),(SELECT convert(varchar(20), Height)+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Heights,\
        convert(varchar(2000),(SELECT convert(varchar(20), Width)+',' from Co_DynamicAttach where DynamicId=a.DynamicId FOR XML PATH(''))) as Widths,\
            e.IsLike,e.IsCollection,e.IsReport,ISNULL(d.IsConcern,0) as IsConcern\
            from Co_Dynamic a\
            inner join Co_Blogger b \
            on a.UserId=b.UserId\
            left join Co_Topic c\
            on a.TopicId=c.TopicId\
            left join Co_DynamicRelated e\
            on a.DynamicId=e.DynamicId and e.UserId=?\
            left join Co_BloggerConcern d\
            on b.BloggerId=d.BloggerId and d.UserId=? and d.IsConcern=1 and b.UserId=d.ConcernUserId\
            where a.WorkId=? and a.DelFlag=0 and (a.Limit = 1 or a.UserId=?) and isnull(e.IsReport,0)=0 and c.TopicId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId); dbparams.add(userId);
        dbparams.add(self.data.WorkId);
        dbparams.add(userId); dbparams.add(topicId);
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    GetBloggerList(searchkey, userId, page, limit) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "BloggerId";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.*,ISNULL(b.IsConcern,0) IsConcern from Co_Blogger a\
        left join Co_BloggerConcern b\
        on a.BloggerId=b.BloggerId and b.UserId=?";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        if (searchkey != "") {
            strsql += " and a.NickName like ?"
            dbparams.add("%" + searchkey + "%");
        }
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    GetConcernTopicList(page, limit, userId) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "LookersCount desc";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.* from Co_Topic a\
        inner join Co_TopicConcern b\
        on a.TopicId=b.TopicId\
        where a.WorkId=? and b.UserId=? and b.IsConcern=1";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(self.data.WorkId);
        dbparams.add(userId);
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    GetConcernList(searchkey, userId, bloggerUserId, page, limit) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "BloggerId";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.*,\
        isnull((select IsConcern from Co_BloggerConcern where ConcernUserId=? and UserId=a.UserId),0) EachConcern,\
        isnull((select IsConcern from Co_BloggerConcern where UserId=? and ConcernUserId=a.UserId),0) IsConcern\
        from Co_Blogger a\
        inner join Co_BloggerConcern b\
        on a.UserId=b.ConcernUserId\
        where b.UserId=? and b.IsConcern=1";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        dbparams.add(userId);
        dbparams.add(bloggerUserId);
        if (searchkey != "") {
            strsql += " and a.NickName like ?"
            dbparams.add("%" + searchkey + "%");
        }
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    GetFansList(searchkey, userId, bloggerUserId, page, limit) {
        var self = this;
        var pageInfo = {};
        pageInfo.key = "BloggerId";
        pageInfo.page = page;
        pageInfo.perPage = limit;
        pageInfo.totalRecord = 0;
        pageInfo.totalPage = 0;
        var strsql = "select a.*,ISNULL((select IsConcern from Co_BloggerConcern where UserId=? and ConcernUserId=a.UserId),0) IsConcern from Co_Blogger a\
        inner join Co_BloggerConcern b\
        on a.UserId=b.UserId\
        where b.ConcernUserId=? and b.IsConcern=1";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(userId);
        dbparams.add(bloggerUserId);
        if (searchkey != "") {
            strsql += " and a.NickName like ?"
            dbparams.add("%" + searchkey + "%");
        }
        var data = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams, pageInfo);
        return { code: 0, data: data, count: pageInfo.totalRecord };
    },
    GetShieldWordList() {
        var self = this;
        var strsql = "select * from Co_ShieldingWord where WorkId=? and DelFlag=0";
        var dbparams = Packages.java.util.ArrayList();
        dbparams.add(self.data.WorkId);
        var list = ORMFunction.GetJsonData(self.data.dbConn, strsql, dbparams);
        return { code: 0, data: { list: list } };
    },
    getCurrTime: function () {
        var self = this;

        return LobsterAPI.getCurrTime(self.data.dbConn, "yyyyMMddhhmmss", 0, 0, 0, 0);
    },
})